package com.lanchetech.dao;
import java.util.Collection;

import com.lanchetech.bean.dto.FreezeStockDTO;
import com.lanchetech.bean.request.PageReq;
import com.lanchetech.bean.vo.*;
import com.lanchetech.entity.Sku;

import java.math.BigDecimal;
import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface SkuMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Sku record);

    int insertSelective(Sku record);

    Sku selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Sku record);

    int updateByPrimaryKey(Sku record);

    int updateBatch(List<Sku> list);

    int updateBatchSelective(List<Sku> list);

    int batchInsert(@Param("list") List<Sku> list);

    int batchInsert2(@Param("list") List<Sku> list);

    List<Sku> findAllBySpuId(@Param("spuId") Long spuId);

    List<Sku> findAllBySpuIds(@Param("spuIds") List<Long> spuIds);

    int updateDeletedBySpuId(@Param("updatedDeleted") Byte updatedDeleted, @Param("spuId") Long spuId);

    int updateFreezeStockBatch(@Param("list") List<FreezeStockDTO> list);

    List<Sku> findAllBySpuIdForUser(@Param("spuId") Long spuId);

    SkuItemVO findOneById(@Param("id") Long id);

    List<Sku> findAllByIds(@Param("ids") List<Long> ids);

    int updateStockAndSalesById(@Param("count") Integer count, @Param("id") Long id);

    int subOneSalesById(@Param("id") Long id);

    int subSalesById(@Param("count") Integer count,@Param("id") Long id);

    Sku findTopOneBySpuId(@Param("spuId") Long spuId);

    List<Sku> findAllPage(PageReq req);

    int updateHiddenBySpuId(@Param("updatedHidden") Byte updatedHidden, @Param("spuId") Long spuId);

    int batchOffline(@Param("list") List<Long> spuIds, @Param("hidden") Byte hidden);

    int updateBatchStock(@Param("list") List<EditSkuStockVO> items);

    int updateBatchPrice(@Param("list") List<EditSkuPriceVO> updateItems);

    List<Long> countSellOutByShopId(Long shopId);

    int batchUpdateCostPriceByTenantId(@Param("rate") BigDecimal rate, @Param("tenantId") Long tenantId, @Param("type") Byte type);

    int updateStockById(@Param("updatedStock") Integer updatedStock, @Param("id") Long id);

    int updateBatchChangePrice(@Param("skuList") List<Sku> skuList);

    int updateCostPriceByChangePrice(@Param("list") List<Long> skuIds);

    int updateDeletedByIdIn(@Param("updatedDeleted") Byte updatedDeleted, @Param("idCollection") Collection<Long> idCollection);

    List<SpuPartnerPriceVO> findMinPartnerPrice(@Param("list") List<Long> spuIds);

    SpuPartnerPriceVO findMinPartnerPriceVOBySpuId(@Param("spuId") Long spuId);

    BigDecimal findMinPartnerPriceBySpuId(@Param("spuId")Long spuId);


    BigDecimal getSkuPriceById(Long skuId);

    ShareSkuVo getSkuById(Long skuId);

    List<ShareSkuVo> getAllByIds(@Param("skuIds") List<Long> skuIds);
}